#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'shawn'

from collections import OrderedDict

"""
字典的排序
"""

def ordered_dict():
    d = OrderedDict()
    d['foo']=1
    d['bar']=2
    d['spam']=3
    d['grok']=4

    for key in d:
        print(key,d[key])

    print(d)

ordered_dict()